import request from "@/axios/index.js";

// 验证码服务
// #获取验证码，如果缺少参数ID，则是创建；存在参数ID，则是刷新验证码
// https://iot.dunji.tech/v1/secure/capture?id=63f965ef87ee6e93b3b95558
export const GetVerifyInit = (params) => {
  return new Promise((resolve, reject) => {
    request(`/v1/secure/capture`, params, "get")
      .then((res) => {
        console.log("res=>api", res);
        if (res.code === 200) {
          resolve(res);
        } else {
          reject(res);
        }
      })
      .catch((err) => {
        reject(err);
      });
  });
};
// # 验证接口， 参数ID是capture的ID，参数loc暂定为x方向的距离
export const GetVerifyResult = (params) => {
  return new Promise((resolve, reject) => {
    request(`/v1/secure/capture/verify`, params, "get")
      .then((res) => {
        console.log("res=>api", res);
        if (res.code === 200) {
          resolve(res);
        } else {
          reject(res);
        }
      })
      .catch((err) => {
        reject(err);
      });
  });
};
